package com.why.entity;

import lombok.Data;

/**
 * @author hy woo
 * @date 2022/6/3 12:04
 */
@Data
public class Result<T> {
    int code = 200;
    String errInfo = "";
    T jdata;

    private static Result OK = new Result(200,"","");

    public static Result OK() {
        return OK;
    }

    public Result(int code, String errInfo, T jdata) {
        this.code = code;
        this.errInfo = errInfo;
        this.jdata = jdata;
    }

    public static Result OK(Object jdata){
        return new Result(200,"",jdata);
    }
    public static Result failed(int code){
        return new Result(code,"",code);
    }
    public static Result failed(int code,String errInfo){
        return  new Result(code,errInfo,null);
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", errInfo='" + errInfo + '\'' +
                ", jdata=" + jdata +
                '}';
    }
}
